package dn.easy.common.commonutils;

import android.content.Context;
import android.os.CountDownTimer;
import android.widget.TextView;

import dn.easy.common.R;
import dn.easy.common.commonwidget.RippleView;

/**
 * Class name 60秒--定时
 * Created by  2017/10/27 0027 10:46.
 * Author by yangjing
 * <p>
 * 支付结果 重发5秒之内处理问题
 */
public class TimesCount extends CountDownTimer {

    private TextView textView;
    private String finishTxt;
    private RippleView viewGroup;
    private Context context;

    public TimesCount(Context context, long millisInFuture, long countDownInterval, TextView view, String finishTxt, RippleView viewGroup) {
        super(millisInFuture, countDownInterval);
        this.textView = view;
        this.finishTxt = finishTxt;
        this.viewGroup = viewGroup;
        this.context = context;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        textView.setTextColor(context.getResources().getColor(R.color.white));
        textView.setClickable(false);
        viewGroup.setEnabled(false);
        textView.setText(+millisUntilFinished / 1000 + "秒后可重发");
    }

    @Override
    public void onFinish() {
        textView.setTextColor(context.getResources().getColor(R.color.white));
        textView.setText(finishTxt);
        if (viewGroup != null) {
            viewGroup.setEnabled(true);
        }
    }
}

